﻿using Abp.Application.Services.Dto;
using Abp.AutoMapper;
using SingleUserMall.Items;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SingleUserMall.ShoppingCarts.VO
{
    /// <summary>
    /// 购物车元素
    /// </summary>
    [AutoMapFrom(typeof(ShoppingCart))]
    public class ShoppingCartItemVO : EntityDto<long>
    {
        internal Item inItem { get; set; }
        internal ItemSpec inItemSpec { get; set; }
        /// <summary>
        /// 图片
        /// </summary>
        public string Picture => inItem?.Picture;
        /// <summary>
        /// 商品名称
        /// </summary>
        public string Name => inItem?.Name;
        /// <summary>
        /// 规格
        /// </summary>
        public string Spec => inItemSpec?.Spec;
        /// <summary>
        /// 商品id
        /// </summary>
        public long? ItemId => inItem?.Id;
        /// <summary>
        /// 规格id
        /// </summary>
        public long? ItemSpecId => inItemSpec?.Id;
        /// <summary>
        /// 商品单价
        /// </summary>
        public decimal Price => (inItemSpec?.Price ?? 0);
        /// <summary>
        /// 商品数量
        /// </summary>
        public int Qty { get; set; }
        /// <summary>
        /// 价格合计
        /// </summary>
        public decimal TotalPrice => Price * Qty;
    }
}
